for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
var blocktrail = require('../'); // require('blocktrail-sdk') when trying example from in your own project
var client = blocktrail.BlocktrailSDK({
apiKey: process.env.BLOCKTRAIL_SDK_APIKEY || "EXAMPLE_BLOCKTRAIL_SDK_NODEJS_APIKEY",
apiSecret: process.env.BLOCKTRAIL_SDK_APISECRET || "EXAMPLE_BLOCKTRAIL_SDK_NODEJS_APISECRET",
testnet: true
});
var randi = (Math.random() * 10000).toFixed();
var passphrase = "example-strong-password";
var walletVersion = blocktrail.Wallet.WALLET_VERSION_V2;
var identifier = "example-wallet-" + randi;
console.log("identifier: " + identifier);
console.log
var getWallet = function() {
return client.createNewWallet({
identifier: identifier,
passphrase: passphrase,
walletVersion: walletVersion,
keyIndex: 9999
})
.progress(function(p) {
console.log('progress', p);
.then(function(r) {
return r[0];
}, function(e) {
if (e.message.match(/already exists/)) {
return client.initWallet({
passphrase: passphrase
} else {
throw e;
}
};
getWallet()
.then(function(wallet) {
console.log('got wallet');
console.log(wallet.getAddressByPath("M/9999'/0/0"));
return wallet;
return wallet.upgradeToV3(passphrase)
.then(function() {
console.log('UPGRADED!');
.catch(function(e) {
console.log(e);
.done();